<template>
	<view class="text-light-black-16">
		<view class="lineGray"></view>
		<view class=" padding">
			<view class="line marginTop">
				<view class="column marginLeft" @click="click(1)">
					<view v-show="false" class="noticeNum line"><text>1</text></view>
					<view class="icon-normal-round line">
						<image class="full " src="../../static/loveicon.png"></image>
					</view>
					<view class="marginTop">赞和收藏</view>

				</view>
				<view class="bigEmpty"></view>
				<view class="column " @click="click(2)">
					<view v-show="false" class="noticeNum line"><text>1</text></view>
					<view class="icon-normal-round line">
						<image class="full" src="../../static/focuicon.png"></image>
					</view>
					<view class="marginTop">关注</view>
				</view>
				<view class="bigEmpty"></view>
				<view class="column " @click="click(3)">
					<view v-show="false" class="noticeNum line"><text>1</text></view>
					<view class="icon-normal-round line">
						<image class="full" src="../../static/sameicon.png"></image>
					</view>
					<view class="marginTop">被同款</view>
				</view>
				<view class="bigEmpty"></view>
				<view class="column marginRight " @click="click(4)">
					<view v-show="false" class="noticeNum line"><text>1</text></view>
					<view class="icon-normal-round line">
						<image class="full" src="../../static/loveicon.png"></image>
					</view>
					<view class="marginTop">评论</view>
				</view>

			</view>
			<view class="lineGray marginTop"></view>
			<view class="marginTop">

				<view class="line marginTop" @click="goMessage(3)">
					<view>
						<image class="icon-normal-round" src="../../static/officeicon.png"></image>
					</view>
					<view class="bigEmpty marginLeft ">
						<view class="line">
							<view class="bigEmpty textblack16 bold line-no-1">
								官方公告
								<view v-show="lastMeassageNum3" class="noticeNum1 line margin-left-0">
									<text>{{lastMeassageNum3}}</text>
								</view>
							</view>
							<view>{{lastSystemTime}}</view>
						</view>
						<view class="marginTop">系统公告查看</view>
					</view>
				</view>

				<view @click="goMessage(4)" hover-class="navigator-hover">
					<view class="line marginTop">
						<view>
							<image class="icon-normal-round" src="../../static/benus.png"></image>
						</view>
						<view class="bigEmpty marginLeft ">
							<view class="line">
								<view class="bigEmpty textblack16 bold line-no-1">收益
									<view v-show="false" class="noticeNum1 line margin-left-0">
										<text>1</text>
									</view>
								</view>
								<view>暂无</view>
							</view>
							<view class="marginTop">收益情况查看</view>
						</view>
					</view>
				</view>
				<view @click="goMessage(1)">
					<view class="line marginTop">
						<view>
							<image class="icon-normal-round" src="../../static/blue-servive.png"></image>
						</view>
						<view class="bigEmpty marginLeft ">
							<view class="line">
								<view class="bigEmpty textblack16 bold line-no-1">服务反馈
									<view v-show="false" class="noticeNum1 line margin-left-0"><text>1</text></view>
								</view>
								<view>暂无</view>
							</view>
							<view class="marginTop">暂无</view>
						</view>
					</view>
				</view>

				<view class="line marginTop" @click="goMessage(2)">
					<view>
						<image class="icon-normal-round" src="../../static/color-pic.png"></image>
					</view>
					<view class="bigEmpty marginLeft ">
						<view class="line">
							<view  class="bigEmpty textblack16 bold line-no-1">
								 AI生成
								<view v-show="lastMeassageNum2" class="noticeNum1 line "><text>{{lastMeassageNum2}}</text></view>
							</view>
							<view>{{lastTaskFinishTime}}</view>
						</view>
						<view class="marginTop">查看AI记录</view>
					</view>
				</view>

				<!--  #ifdef   MP-WEIXIN -->
				<view class="marginTop" style="position: relative;">

					<view class="line " style="position: absolute; left: 0; top: 0;">
						<view>
							<image class="icon-normal-round" src="../../static/wxq.png"></image>
						</view>
						<view class="bigEmpty marginLeft ">
							<view class="line">
								<view class="bigEmpty textblack16 bold">用户交流群</view>
								<view></view>
							</view>
							<view class="marginTop"></view>
						</view>
					</view>

					<view class="width100" style="opacity: 0; position: absolute; left: 0; top: 0;">
						<cell iconBorderRadius="80" :startmessage='startmessage' :completemessage="completemessage"
							:url="wxurl" />
					</view>

				</view>

				<!--  #endif -->

			</view>
		</view>
	</view>

</template>

<script>
	import request from '/common/request.js';
	export default {
		components: {
			// #ifdef MP-WEIXIN
			cell: "plugin://chatGroupPlugin/cell"
			// #endif

		},
		data() {
			return {
				wxurl: "https://work.weixin.qq.com/gm/468b6fa398becc4621a6709863400ddf",
				lastTaskFinishTime: "暂无",
				lastSystemTime: '暂无',
				lastMeassageNum2: "",
				lastMeassageNum3: "",
			}
		},
		onShareAppMessage(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		// 自定义页面的分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		onShow: function() {

			console.log("message on show")
			this.requstData()
		},
		methods: {
			readMeassage() {
				const that = this;
				var token = uni.getStorageSync("token");
				if (token) {
					const url = getApp().globalData.apiUrl + "/api/v1/user/readMeassage";

					request(url, "POST", {

						}, uni.getStorageSync("token"))
						.then(function(res) {
							console.log('返回正确回调', res)
							
						}, function(err) {
							console.log('返回错误回调', err)
						})

				}

			},

			requstData() {
				var token = uni.getStorageSync("token");
				if (token) {
					const that = this;
					const url = getApp().globalData.apiUrl + "/api/v1/user/messageInfo";
					request(url, "GET", {
							page: 0,
							size: 100
						}, uni.getStorageSync("token"))
						.then(function(res) {
							console.log('返回正确回调', res)
							that.lastTaskFinishTime = res.data.newTaskFinish.time
							that.lastSystemTime = res.data.newSystemMsg.time
							that.lastMeassageNum2 = res.data.newNum2
							if (that.lastMeassageNum2 > 99) {
								that.lastMeassageNum2 = "99+";
							}
							that.lastMeassageNum3 = res.data.newNum3
							if (that.lastMeassageNum3 > 99) {
								that.lastMeassageNum3 = "99+";
							}


						}, function(err) {
							console.log('返回错误回调', err)
						})
				}
			},

			goMessage(index) {
				var newTime = uni.getStorageSync("newTime");
				console.log("click----")
				console.log(newTime)
				uni.setStorageSync("readTime", newTime);
				uni.hideTabBarRedDot({
					index: 3
				})
				uni.navigateTo({
					url: "/pages/Message/OfficeMessage?type=" + index
				})
				this.readMeassage();
			},

			click(num) {

				switch (num) {
					case 1:
						uni.navigateTo({
							url: "/pages/Love/Love"
						})
						break
					case 2:
						uni.navigateTo({
							url: "/pages/Focus/Focus"
						})
						break
					case 3:
						uni.navigateTo({
							url: "/pages/SameProdutct/SameProdutct"
						})
						break
					case 4:
						uni.navigateTo({
							url: "/pages/Comment/Comment"
						})
						break
				}

			}

		}
	}
</script>

<style>
	@import "../../common/uni.css";

	.noticeNum {
		margin-bottom: -30rpx;
		height: 50rpx;
		width: 50rpx;
		color: white;
		display: flex;
		font-size: 20rpx;

		background-color: #D000FF;
		align-self: flex-end;
		z-index: 20;
		border-radius: 40rpx
	}

	.noticeNum1 {
		height: 50rpx;
		width: 50rpx;
		color: white;
		display: flex;
		margin-top: -10rpx;
		margin-left: 5rpx;
		background-color: #D000FF;
		z-index: 20;
		font-size: 20rpx;
		border-radius: 40rpx
	}
</style>